﻿using NoteBook_Product.Extensions;
using NoteBook_Product.Models;
using Prism.Commands;
using Prism.Regions;
using System.Collections.ObjectModel;

namespace NoteBook_Product.ViewModels
{
    public class SettingViewModel
    {
        public SettingViewModel(IRegionManager regionManager)
        {
            _regionManager = regionManager;
            MenuBars = new();
            CreateMenuBar();
            NavigateCommand = new(Navigate);
        }

        public ObservableCollection<MenuBar>? MenuBars { get; set; }

        public DelegateCommand<MenuBar> NavigateCommand { get; private set; }

        public readonly IRegionManager _regionManager;

        private void Navigate(MenuBar bar)
        {
            if (string.IsNullOrEmpty(bar?.Namespace)) return;

            _regionManager.Regions[PrismManager.SettingViewRegionName].RequestNavigate(bar.Namespace);
        }

        private void CreateMenuBar()
        {
            MenuBars?.Add(new("Palette", "个性化", "SkinView"));
            MenuBars?.Add(new("Cog", "系统设置", ""));
            MenuBars?.Add(new("Information", "关于更多", "AboutView"));
        }
    }
}
